﻿namespace express.bttree;

public class Utils
{
    public static Boolean comparable(Object v1, Object v2) {
        if(v1 is Boolean && v2 is Boolean) {
            return true;
        }
        if((v1 is Int32 || v1 is Int64) && (v2 is Int32 || v2 is Int64)) {
            return true;
        }
        if(v1 is String && v2 is String) {
            return true;
        }
        return false;
    }
    
    public static Operator GetOperator(String op) {
        switch (op) {
            case "=":
            case "==":
                return Operator.eq;
            case ">":
                return Operator.gt;
            case ">=":
                return Operator.gte;
            case "<":
                return Operator.lt;
            case "<=":
                return Operator.lte;
            case "<>":
            case "!=":
                return Operator.ne;
            default:
                return Operator.nil;
        }
    }
    public static bool IsOp(String str)
    {
        Operator op = GetOperator(str);
        if (op == Operator.nil) {
            return false;
        } else
        {
            return true;
        }
    }
}